<template>
    <div class="app-container">
        <div>
            <el-divider content-position="center">风险限值</el-divider>
            <el-form ref="calculateconfRef" :model="form" :rules="rules" label-width="150px">

                <el-form-item label="基准风险值" prop="base">
                    <el-input :disabled="calculateconfOpen" v-model="form.base" placeholder="请填写基准风险值" clearable
                        style="width: 300px" />

                </el-form-item>

                <el-form-item label="风险限值" prop="limit">
                    <el-input :disabled="calculateconfOpen" v-model="form.limit" placeholder="请填写风险限值" clearable
                        style="width: 300px" />
                </el-form-item>

                <el-button style="float: right;  margin-left: 10px" type="primary" plain icon="Check"
                    @click="submitForm">提交</el-button>
                <el-button style="float: right;  margin-left: 10px" type="primary" plain icon="Unlock"
                    @click="toUnlock">解锁 </el-button>

            </el-form>
        </div>



    </div>
</template>

<script setup name="Calculateconf">
import { infoCalculateconf, editCalculateconf } from "@/api/factoryInfo/calculateconf/calculateconf";
const { proxy } = getCurrentInstance();
import { ref } from 'vue';

const calculateconfOpen = ref(true);

const data = reactive({
    form: {
    },
    queryParams: {

    },
    rules: {
        base: [{ required: true, message: "最大值不能为空", trigger: "blur" }],
        limit: [{ required: true, message: "最大值不能为空", trigger: "blur" }],
    },
});




const { queryParams, form, rules } = toRefs(data);

function toUnlock() {
    debugger
    calculateconfOpen.value = false;
}


getInfo();
function getInfo() {
    infoCalculateconf({}).then(response => {
        form.value = response.data;
    });
}



function submitForm() {
    proxy.$refs["calculateconfRef"].validate(valid => {
        if (valid) {
            editCalculateconf(form.value).then(response => {
                proxy.$modal.msgSuccess("修改成功");
                calculateconfOpen.value = true;
                getInfo();
                proxy.$modal.msgSuccess("设置成功");
            });
        }

    });
};



</script>


<style lang='scss' scoped>
.radio {
    margin: 20px;
}
</style>